<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
define('PER_PAGE', 12);

class Frontend extends Front_Controller {
    function __construct () {
        parent::__construct();
        $this->load->model('dish/dish_model');
        $this->menu->parent_active('trang-chu');
    }
    
    function index () {
        $data_slider =  $this->dish_model->get_dishs(array('limit' => 5, 'is_spec' => 1, 'status' => 1, 'frontend' => 1));
        $data_feature =  $this->dish_model->get_dishs(array('limit' => 6, 'is_hot' => 1, 'status' => 1, 'frontend' => 1));

        //show category in id
        $array_categories = array(135,136,137,141,139);
        $data_tab = array();
        foreach ($array_categories as $category_id) {
            $category = $this->dish_model->get_categories(array('category_id' => $category_id, 'status' => 1), false, false);
            $data_tab[$category_id] = $category[0];
            $data_tab[$category_id]['sub'] =  $this->dish_model->get_dishs(array('limit' => 8, 'category_id' => $category_id, 'frontend' => 1, 'status' => 1));
        }
    
        // random dish
        $total_random = 6;
        $data_random = $this->dish_model->get_random_dish($total_random);

        $this->smarty->assign('data_slider', $data_slider);
        $this->smarty->assign('data_feature', $data_feature);
        $this->smarty->assign('data_tab', $data_tab);
        $this->smarty->assign('data_random', $data_random);
        $this->smarty->assign('page_title', "Cùng nấu ăn với các món ăn ngon dễ làm, món ngon cuối tuần cho người thân");
        $this->smarty->assign('description', "");
        $this->smarty->display('fontend');
    }

    public function logout() {
        $this->session->unset_userdata('logged_in');
        session_destroy();

        // Logs off session from website
        $this->facebook->destroySession();
        // Make sure you destory website session as well.
        redirect();
    }

}


